package day1106.Map;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;

public class Map {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        java.util.Map<String,String> map = new HashMap<>();
        map.put("狗","dog");
        map.put("猫","cat");
        map.put("鱼","fish");
        map.put("猪","pig");
        Set<java.util.Map.Entry<String, String>> entries = map.entrySet();
        System.out.println("请输入汉字：");
        String a = input.next();
        int pos =0;
        for (java.util.Map.Entry<String, String>o:entries){

            if (a.equals(o.getKey())) {
                System.out.println(o.getKey() + "=" + o.getValue());
                break;
            }
            pos++;
        }
        if (pos>=map.size()){
            System.out.println("没有找到该汉字");
        }
        System.out.println("请输入单词：");
        String b = input.next();
        pos=0;
        for (java.util.Map.Entry<String, String>o:entries){
            if (b.equals(o.getValue())) {
                System.out.println(o.getValue() + "=" + o.getKey());
                break;
            }
            pos++;
        }
        if (pos>=map.size()){
            System.out.println("没有找到该单词");
        }
    }
}
